<%@page import="org.jeecgframework.web.util.StaticValue" %>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>查看备件详情</title>
    <t:base type="jquery,easyui,tools,DatePicker"></t:base>
    <script type="text/javascript" src="plug-in/mutiLang/zh-cn.js"></script>
    <link rel="stylesheet" type="text/css" href="plug-in/accordion/css/accordion.css">
    <script type="text/javascript" src="plug-in/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="plug-in/lhgDialog/lhgdialog.min.js"></script>
    <script type="text/javascript" src="plug-in/jquery-plugs/hftable/jquery-hftable.js"></script>
    <link rel="stylesheet" href="plug-in/uploadify/css/uploadify.css" type="text/css"/>
    <script type="text/javascript" src="plug-in/uploadify/jquery.uploadify-3.1.min.js"></script>
</head>

<body>
<div style="margin-bottom:10px;">
    <img style="margin-bottom:-7px" src="../plug-in/login/images/dispatch bill.png">
    <span class="list-title">${cbsEquipmentApplyEntity.recordId}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <span style="font-size:13px;">状态：
        <c:if test="${cbsEquipmentApplyEntity.status==1}"><span class="color-red">待审批</span></c:if>
        <c:if test="${cbsEquipmentApplyEntity.status==2}"><span>审批已通过</span></c:if>
        <c:if test="${cbsEquipmentApplyEntity.status==3}"><span>审批未通过</span></c:if>
    </span>
</div>

<div class="subtitle">
    <p>关联信息</p><c:if test="${code==1}"><span style="color: red">序列号验证未通过，请联系CSA协助核查。</span></c:if>
    <c:if test="${code!=1}"><span style="color: red">序列号验证已通过。</span></c:if>
    <table class="nobordertable noborder">
        <tbody>
        <tr>
            <td class="al_r" width="20%">
                <label>服务单号CR:</label>
            </td>
            <td width="30%">
                ${cbsService.code}
            </td>
            <td class="al_r" width="20%">
                <label>SR:</label>
            </td>
            <td width="30%">
                <input class="inputxt" readonly="readonly" name="sr" id="sr" value="${cbsService.sr}"/>
            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%">
                <label>SO:</label>
            </td>
            <td width="30%">
                <input class="inputxt" name="so" id="so" value="${cbsService.so}" readonly="readonly"/>
            </td>
            <td class="al_r" width="20%">

            </td>
            <td width="30%">

            </td>
        </tr>
                    <tr>
                <td class="al_r" width="20%">
                    <label>故障代码:</label>
                </td>
                <td width="30%">
                        ${cbsService.errorCode}
                </td>
                <td class="al_r" width="20%">
                   <label>服务描述:</label>
                </td>
                <td width="30%">
 						${cbsService.description}
                </td>
            </tr>
        </tbody>
    </table>
</div>
<div class="subtitle">
    <p>设备信息</p>
    <input type="hidden" name="id" id="id" value="${cbsEquipmentApplyEntity.id}">
    <table class="nobordertable noborder">
        <tbody>
        <tr>
            <td class="al_r" width="20%">
                <label>序列号:</label>
            </td>
            <td width="30%">
                <input class="inputxt" type="hidden" value="${cbsEquipmentApplyEntity.sn}" id="sn"
                       name="zyEquipmentSpareSn"/>
                ${cbsEquipmentApplyEntity.sn}&nbsp;&nbsp;<span class="color-blue" onclick="viewDetail('${spareId}')">[设备详情]</span>
            </td>
            <td class="al_r" width="20%">
                <label>机型:</label>
            </td>
            <td width="30%">
                ${cbsEquipmentApplyEntity.equipmentType}
            </td>
        </tr>
        </tbody>
    </table>
    <div style="margin-top:20px; width: 98%; margin: 10px auto;"><span style="font-weight: bold;">设备历史发货</span></div>
    <table class="ftable">
        <tbody>
        <tr>
            <th>发货单号</th>
            <th>备件型号</th>
            <th>备件号</th>
            <th>物流</th>
            <th>预计到货时间</th>
            <th>发货状态</th>
            <th>创建时间</th>
        </tr>
        <c:forEach items="${cbsDelinerEquipmentHql}" var="a">
            <tr>
                <td><span class="color-blue" style="text-decoration: underline"
                          onclick="addDetailsTab('${a.deliverId.id}')">${a.deliverId.code}</span></td>
                <td>${a.typeId.typeDesc}</td>
                <td>
                    <c:if test="${a.typeId.typeDesc=='其他'}">${a.equipmentApplyDetailId.item}</c:if>
                    <c:if test="${a.typeId.typeDesc!='其他'}">${a.itemId.item}</c:if>
                </td>
                <td>${a.deliverId.deliverLogistics}</td>
                <td>${fn:substring(a.deliverId.expectTime,0,19)}</td>
                <td>
                    <c:if test="${a.deliverId.status==1}">CSA待发货</c:if>
                    <c:if test="${a.deliverId.status==2}">CSA已发货</c:if>
                    <c:if test="${a.deliverId.status==3}">CSA取消发货</c:if>
                    <c:if test="${a.deliverId.status==4}">欠货中</c:if>
                    <c:if test="${a.deliverId.status==5}">物流待发货</c:if>
                    <c:if test="${a.deliverId.status==6}">物流待签收</c:if>
                    <c:if test="${a.deliverId.status==7}">已签收</c:if>
                </td>
                <td>${fn:substring(a.deliverId.createDate,0,19)}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<div class="subtitle">
    <p>备件申请</p>
    <div class="l-div" id="addEquTab">
        <input id="applyId" type="hidden" value="${cbsEquipmentApplyEntity.id}"/>
        <input type="hidden" id="cbsServiceId" value="${cbsEquipmentApplyEntity.serviceId}">
        <c:forEach items="${cbsEquipmentApplyDetailHql}" var="cbs">
            <table class="nobordertable noborder" style="border: none;" id="${cbs.id}t">
                <tbody>
                <tr>
                    <td class="al_r" width="20%">
                        <label>备件类型:</label>
                    </td>
                    <td width="30%">
                        <input type="hidden" name="applyDetailId" value="${cbs.id}">
                        <input name="typeId" type="hidden" id="${cbs.id}" value="${cbs.typeId.id}"/>
                        <input class="inputxt" name="typeDes" readonly="readonly" uuid="*" type="text" id="${cbs.id}0"
                               value="${cbs.typeDes}"/>
                            <%--<input class="button" value="选择" type="button" onclick="getTree(this,'${cbs.id}')"/>--%>
                    </td>
                    <td class="al_r" width="20%">
                        <label>备件号:</label>
                    </td>
                    <td width="30%">
                        <select id="${cbs.id}item" onchange="getItemDesc(this)" name="itemId" disabled="disabled">
                            <option value="${cbs.itemId.id}">${cbs.item}</option>
                        </select>
                        <input name="item" id="${cbs.id}in" type="text" style="display: none" value="${cbs.item}"
                               readonly="readonly">
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label>备件描述:</label>
                    </td>
                    <td colspan="3">
                        <c:if test="${cbs.typeId.typeDesc=='其他'}"><span class="color-red"
                                                                        id="${cbs.id}span">${cbs.item}</span></c:if>
                        <c:if test="${cbs.typeId.typeDesc!='其他'}"><span class="color-red"
                                                                        id="${cbs.id}span">${cbs.itemId.itemDesc}</span></c:if>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%">
                        <label>数量:</label>
                    </td>
                    <td width="30%">
                        <input name="total" value="${cbs.total}" readonly="readonly"/>
                    </td>
                    <td class="al_r" width="20%">
                        <label>申请优先级:</label>
                    </td>
                    <td width="30%">
                        <select name="applyLayer" disabled="disabled">
                            <c:forEach items="${tSTypeHql}" var="tst">
                                <option value="${tst.typecode}" ${tst.typecode==cbs.applyLayer?"selected":""}>${tst.typename}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="al_r" width="20%"><label>备件说明:</label></td>
                    <td colspan="3"><textarea name="memo" cols="50" readonly="readonly">${cbs.memo}</textarea></td>
                </tr>
                </tbody>
            </table>
        </c:forEach>
    </div>
    <div style="margin-top:20px;"><span style="font-weight: bold;">说明</span></div>
    <div class="line"></div>
    <table class="nobordertable noborder" style="border: none;">
        <tbody>
        <tr>
            <td class="al_r" width="20%">
                <label>申请理由:</label>
            </td>
            <td colspan="3">
                <select id="applyReason" disabled="disabled">
                    <c:forEach items="${TSTypeList}" var="tst">
                        <option value="${tst.typename}" ${tst.typename==cbsEquipmentApplyEntity.applyReason?"selected":""}>${tst.typename}</option>
                    </c:forEach>
                </select>
            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%">
                <label>上传附件:</label>
            </td>
            <td colspan="3">
                <%--<input type="file" value="上传附件" id="fileUpload" />&nbsp;&nbsp;--%>
                <c:forEach items="${fileList}" var="fl">
                    <c:if test="${fl.id!=null}">
                        <p name="fileId" id="li_file_${fl.id}" style="background-color: white"><span class="color-blue"><a
                                style="color: blue"
                                href="fileUploadController.do?downLoadFile&fileLogId=${fl.id}">${fl.oldFileName}</a></span>
                        </p>
                    </c:if>
                </c:forEach>
            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%" valign="top">
                <label>备注:</label>
            </td>
            <td width="80%">
                <textarea style="width: 100%; height: 80px;" id="memo"
                          readonly="readonly">${cbsEquipmentApplyEntity.memo}</textarea>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<div class="subtitle">
    <p>故障备件信息</p>
    <table class="ftable">
        <tbody id="faultEquipment">
        <tr>
            <th>备件类型</th>
            <th>备件号</th>
            <th>备件序列号</th>
            <th>备件二维码</th>
            <%--<th>操作</th>--%>
        </tr>
        <c:forEach items="${cbsFaultEquipmentList}" var="a">
            <tr id="${a.id}">
                <td>${a.typeDes}</td>
                <td>${a.item}</td>
                <td>${a.sn}</td>
                <td>${a.equipmentErcode}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<div class="subtitle">
    <p>收货人信息</p>
    <table class="nobordertable noborder" style="border: none;">
        <tbody>
        <tr>
            <td class="al_r" width="20%">
                <label>是否自提:</label>
            </td>
            <td colspan="3">
                <input type="radio" name="radiobutton" value="是" ${cbsEquipmentApplyEntity.zt==1?"checked":""}
                       onclick="getValue()" disabled="disabled"> 是
                <input type="radio" name="radiobutton" value="否" ${cbsEquipmentApplyEntity.zt==2?"checked":""}
                       onclick="getValue()" disabled="disabled"> 否
            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%">
                <label>姓名:</label>
            </td>
            <td width="30%">
                <input id="userName" value="${cbsEquipmentApplyEntity.userName}" readonly="readonly">
            </td>
            <td class="al_r" width="20%">
                <label>电话:</label>
            </td>
            <td width="30%">
                <input id="phone" value="${cbsEquipmentApplyEntity.phone}" readonly="readonly">
            </td>
        </tr>
        <tr id="tr1">
            <td class="al_r" width="20%">
                <label>收货地址:</label>
            </td>
            <td width="30%">
                <select style="width:auto" onchange="getShi()" id="sheng" disabled="disabled">
                    <c:forEach items="${tSTerritoryHql}" var="t">
                        <option value="${t.territoryCode}" ${t.id==cbsEquipmentApplyEntity.sheng.id?"selected":""}>${t.territoryName}</option>
                    </c:forEach>
                </select>
                <input type="hidden" id="city" value="${cbsEquipmentApplyEntity.shi.territoryCode}">
                <select style="width: 45%" id="shi" disabled="disabled">
                </select>
            </td>
            <td class="al_r" width="20%">
                <label>影院名称:</label>
            </td>
            <td width="30%">
                <input value="${cbsEquipmentApplyEntity.cinemaName}" id="cinemaName" readonly="readonly">
            </td>
        </tr>
        <tr id="tr2">
            <td></td>
            <td colspan="3" style="padding: 0 8px;"><input id="address" style="width:50%"
                                                           value="${cbsEquipmentApplyEntity.address}"
                                                           readonly="readonly"></td>
        </tr>
        <tr id="tr3">
            <td class="al_r"><label>自提仓库:</label></td>
            <td colspan="3">
                <select id="warehouse" onchange="getWarehouseAddress()" disabled="disabled">
                </select>
                &nbsp;&nbsp;
                <span id="span"></span>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<div class="subtitle">
    <p>发货信息</p>
    <table class="ftable">
        <tbody>
        <tr>
            <th>发货状态</th>
            <th>预计到货时间</th>
            <th>发货单号</th>
            <th>备件型号</th>
            <th>备件号</th>
            <th>物流</th>
            <th>创建时间</th>
        </tr>
        <c:forEach items="${list}" var="li">
            <c:forEach items="${li}" var="l">
                <tr>
                    <td>
                        <c:if test="${l.deliverId.status==1}">CSA待发货</c:if>
                        <c:if test="${l.deliverId.status==2}">CSA已发货</c:if>
                        <c:if test="${l.deliverId.status==3}">CSA取消发货</c:if>
                        <c:if test="${l.deliverId.status==4}">欠货中</c:if>
                        <c:if test="${l.deliverId.status==5}">物流待发货</c:if>
                        <c:if test="${l.deliverId.status==6}">物流待签收</c:if>
                        <c:if test="${l.deliverId.status==7}">已签收</c:if>
                    </td>
                    <td>${fn:substring(l.deliverId.expectTime,0,19)}</td>
                    <td>${l.deliverId.code}</td>
                    <td>
                            ${l.typeId.typeDesc}
                    </td>
                    <td>
                        <c:if test="${l.typeId.typeDesc=='其他'}">${l.equipmentApplyDetailId.item}</c:if>
                        <c:if test="${l.typeId.typeDesc!='其他'}">${l.itemId.item}</c:if>
                    </td>
                    <td>${l.deliverId.deliverLogistics}</td>
                    <td>${fn:substring(l.deliverId.createDate,0,19)}</td>
                </tr>
            </c:forEach>
        </c:forEach>
        </tbody>
    </table>
</div>
<div class="subtitle">
    <p>申请人信息</p>
    <table class="nobordertable noborder">
        <tbody>
        <tr>
            <td class="al_r" width="20%">
                <label>申请人:</label>
            </td>
            <td width="30%">
                ${cbsEquipmentApplyEntity.createName}
            </td>
            <td class="al_r" width="20%">
                <label>所属单位:</label>
            </td>
            <td width="30%">
                ${shortname}
            </td>
        </tr>
        <tr>
            <td class="al_r" width="20%">
                <label>电话:</label>
            </td>
            <td width="30%">
                ${mobilePhone}
            </td>
            <td class="al_r" width="20%">

            </td>
            <td width="30%">

            </td>
        </tr>
        </tbody>
    </table>
</div>
<div class="subtitle">
    <p>日志</p>
    <table class="ftable">
        <tbody>
        <tr>
            <th>操作人</th>
            <th>时间</th>
            <th>描述</th>
        </tr>
        <c:forEach items="${cbsHandleLogHql}" var="cbs" varStatus="a">
            <c:if test="${a.index<5}">
                <tr>
                    <td>${cbs.createName}</td>
                    <td>${fn:substring(cbs.createDate,0,19)}</td>
                    <td>${cbs.description}。</td>
                </tr>
            </c:if>
        </c:forEach>
        </tbody>
    </table>
</div>
<div class="subtitle">
    <p>附件列表</p>
    <table class="ftable">
        <tr>
            <th>文件名</th>
            <th>上传时间</th>
            <th>上传人</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${fileList}" var="file">
            <tr>
                <td>${file.oldFileName}</td>
                <td><fmt:formatDate value='${file.createDate}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                <td>${file.createName}</td>
                <td>
                    <span class="color-blue"><a
                            href="fileUploadController.do?downLoadFile&fileLogId=${file.id}">[下载]</a></span>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>
</body>
</html>
<script type="text/javascript">
    if (${cbsEquipmentApplyEntity.zt==2}) {
        $("#tr3").hide();
    } else {
        $.ajax({
            url: "cbsServiceController.do?getWarehouse",
            cache: false,
            dataType: 'json',
            type: 'POST',
            error: function () {// 请求失败处理函数
            },
            success: function (data) {
                var warehouseHql = data.warehouseHql;
                $("#warehouse").html("");
                var html = "";
                for (var i = 0; i < warehouseHql.length; i++) {
                    html += "<option value='" + warehouseHql[i].id + "'>" + warehouseHql[i].name + "</option>"
                }
                $("#warehouse").append(html);
                $("#warehouse option[value='${cbsEquipmentApplyEntity.warehouseId}']").attr("selected", "selected");
            }
        });
        $("#tr1").hide();
        $("#tr2").hide();
    }


    function delSparePart(uuid, obj) {
        $("#" + uuid + "t").remove();
        $(obj).remove();
    }

    function getItemDesc(obj) {
        var uuid = obj.id.substring(0, 32);
        $.ajax({
            url: "cbsServiceController.do?getItemDesc",
            data: {
                "id": obj.value,
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            error: function () {// 请求失败处理函数
            },
            success: function (data) {
                if (uuid != null) {
                    $("#" + uuid + "span").text(data.itemDesc);
                } else {
                    $("#" + obj.id + "span").text(data.itemDesc);
                }

            }
        });
    }

    function getShi() {
        var sheng = $("#sheng").val();
        $.ajax({
            url: "cbsServiceController.do?getShi",
            data: {
                "sheng": sheng,
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            error: function () {// 请求失败处理函数
            },
            success: function (data) {
                $("#shi").html("");
                var html = "";
                for (var i = 0; i < data.length; i++) {
                    html += "<option value='" + data[i].territoryCode + "'>" + data[i].territoryName + "</option>"
                }
                $("#shi").append(html);
            }
        });
    }

    function getWarehouseAddress() {
        var id = $("#warehouse").val();
        var type = 1;
        $.ajax({
            url: "cbsServiceController.do?getWarehouse",
            data: {
                "type": type,
                "id": id
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            error: function () {// 请求失败处理函数
            },
            success: function (data) {
                var a = "";
                var tstList = data.tstList;
                if (tstList != null) {
                    for (var i = 0; i < tstList.length; i++) {
                        a += tstList[i][3];
                    }
                    $("#span").text(a);
                }
            }
        });
    }

    /*设备详情*/
    function viewDetail(id) {
       if (null != id && id != '') {
       		addOneTab('设备详细', 'zyEquipmentSpareController.do?goView&id=' + id);
        } else {
            tip("设备不存在！");
        }
    }

    /*发货单详情*/
    function addDetailsTab(id) {
        addOneTab("发货单详情", "cbsDelinerController.do?goDeliverDetails&id=" + id + "");
    }

    $(function () {
        getShi();
    })
</script>